package com.jf.jsp.exercise2;

import com.jf.jsp.Monster;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-09-01
 * Time:19:24
 */
@WebServlet(name = "FilterServlet", urlPatterns = "/filterServlet")
public class FilterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<Monster> monsters = new ArrayList<>();
        monsters.add(new Monster("幽魂", "头槌", 65.2));
        monsters.add(new Monster("虎先锋", "风卷残云", 83.6));
        monsters.add(new Monster("广智", "烈火斩", 49.1));
        req.setAttribute("monsters", monsters);
        req.getRequestDispatcher("/exercise2/show.jsp").forward(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
